<template>
  <div class="pagestyle">
    <list_controller
      ref="zujianname"
      :options="state.optionsList"
      pageName=""
      @tabChange="tabChange"
      :tabName="state.tabNameData"
      @yinyong="yinyong1"
    >
      <template v-slot:opraCurdBtnAll>
        <el-button class="btn" type="primary" link @click="addBtn('mul')">
          <el-icon style="margin-right: 2px">
            <svg-icon
              class-name="search-icon"
              icon-class="addtotal"
            /> </el-icon
          >新增
        </el-button>
        <el-button class="btn" type="primary" link @click="deleteBtn('mul')">
          <el-icon>
            <DeleteFilled /> </el-icon
          >删除
        </el-button>
      </template>
      <template v-slot:expandFixed="row">
        <div
          class="expand-wrapper"
          v-if="row.row.row.gasBaseExFactorySpecificImitateSubIndexList"
        >
          <vxe-table
            border
            :data="row.row.row.gasBaseExFactorySpecificImitateSubIndexList"
          >
            <vxe-column
              v-for="(item, index) in state.optionsList.subtableheads"
              :field="item.field"
              :title="item.title"
              :params="{ name: item.name }"
              :width="item.width ? item.width : ''"
              :key="index"
            >
            <template  #default="{ row }">
             <!-- <span v-if="item.title === '【高】量程上/下限'">
              {{ row['highRangeUp']+'/'+row['highRangeDown'] }}</span>
              <span v-if="item.title === '【低】量程上/下限'">
                {{ row['lowRangeUp']+'/'+row['lowRangeDown'] }}</span>
             <span v-else>{{ row[item.field] }}</span> -->
             <span>{{ row[item.field] }}</span>
            </template>
            </vxe-column>
          </vxe-table>
        </div>
        <div class="expand-wrapper" v-if="row.row.row.specificSwitchSubIndexList">
          <vxe-table border :data="row.row.row.specificSwitchSubIndexList">
            <vxe-column
              v-for="(item, index) in state.optionsList.subtableheads"
              :field="item.field"
              :title="item.title"
              :params="{ name: item.name }"
              :width="item.width ? item.width : ''"
              :key="index"
            >
            <template  #default="{ row }">
                <span v-if="item.field==='normalLogic'">
<!-- 出厂特性模块-常态逻辑 -->
{{ row['normalLogic']=='0'?'低电平':'高电平' }}</span>
             <span v-else>{{ row[item.field] }}</span>
             <!-- <span>{{ row[item.field] }}</span> -->
            </template>
            </vxe-column>
          </vxe-table>
        </div>
        <!-- <div class="expand-wrapper" v-if="row.row.row.sensorAddChildList">
                  <vxe-table border :data="row.row.row.sensorAddChildList">
                      <vxe-column v-for="(item,index) in state.optionsList.subtableheads" :field="item.field"
                          :title="item.title" :params="{name:item.name}" :width="item.width?item.width:''"
                          :key="index">
                      </vxe-column>
                  </vxe-table>
              </div> -->
      </template>
      <template v-slot:opraCurdBtn1="row">
        <span>
          <el-button
            type="primary"
            link
            size="small"
            @click="editBtn(row.row.row)"
            >编辑</el-button
          >
          <el-button
            type="primary"
            :disabled="row.row.row.refStatus == '已引用'"
            link
            size="small"
            @click="deleteBtn(row.row.row)"
            >删除</el-button
          >
        </span>
      </template>
    </list_controller>
    <!-- 新增弹框模拟量 -->
    <teleport to="body">
      <vxe-modal
        esc-closable
        destroy-on-close
        :lock-view="false"
        :width="1100"
        :height="auto"
        v-model="state.addModal"
        resize
        :mask="true"
      >
        <template #title>
          <div class="w100 h100 fsc mask_title">{{ state.modalTitle }}</div>
        </template>
        <template #default>
          <div class="form_box">
            <el-form
              ref="formRef"
              :model="state.formData"
              :rules="state.rules"
              label-position="top"
            >
              <div v-if="state.tabName == 'simulate'">
                <el-row :gutter="20">
                  <el-col :span="7">
                    <el-form-item label="名称" prop="deviceName">
                      <el-input
                        clearable
                        v-model="state.formData.deviceName"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="7">
                    <el-form-item label="主索引" prop="primaryIndex">
                      <el-input
                        clearable
                        oninput="value=value.replace(/[^\d]/g,'')"
                        v-model.number="state.formData.primaryIndex"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="7">
                    <el-form-item label="子索引" prop="">
                      <!-- prop="subIndex" -->
                      <el-switch
                        v-model="state.formData.subIndex"
                        @change="hasChildChange"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="7">
                    <!-- v-if="!state.formData.hasChild" -->
                    <el-form-item label="单位" prop="unit">
                      <el-input
                        clearable
                        v-model="state.formData.unit"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="7">
                    <!--  v-if="!state.formData.hasChild" -->
                    <el-form-item label="低量程">
                      <el-input
                            clearable
                            oninput="value=value.replace(/[^\d.]/g,'')"
                            v-model.number="state.formData.lowRangeUp"
                            placeholder="请输入"
                          >
                          </el-input>
                      <!-- <div class="inputrange fbc">
                        <el-input
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          clearable
                          v-model.number="state.formData.lowRangeUp"
                          placeholder="请输入上限"
                        >
                        </el-input>
                        <span>-</span>
                        <el-input
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          clearable
                          v-model.number="state.formData.lowRangeDown"
                          placeholder="请输入下限"
                        >
                        </el-input>
                      </div> -->
                    </el-form-item>
                  </el-col>
                  <el-col :span="7">
                    <!-- v-if="!state.formData.hasChild" -->
                    <el-form-item label="高量程">
                      <el-input
                            clearable
                            oninput="value=value.replace(/[^\d.]/g,'')"
                            v-model.number="state.formData.highRangeUp"
                            placeholder="请输入"
                          >
                          </el-input>
                      <!-- <div class="inputrange fbc">
                        <el-input
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          clearable
                          v-model.number="state.formData.highRangeUp"
                          placeholder="请输入上限"
                        >
                        </el-input>
                        <span>-</span>
                        <el-input
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          clearable
                          v-model.number="state.formData.highRangeDown"
                          placeholder="请输入下限"
                        >
                        </el-input>
                      </div> -->
                    </el-form-item>
                  </el-col>
                  <el-col :span="24" v-if="state.formData.subIndex">
                    <p class="mask_sub_title fbc">
                      <span>
                        <svg-icon
                          class-name="search-icon"
                          icon-class="dot"
                        />子索引</span
                      >
                      <el-button type="primary" @click="childAddClick" link>
                        <Plus />新增</el-button
                      >
                    </p>
                  </el-col>
                  <el-row
                    v-if="state.formData.subIndex"
                    :gutter="20"
                    style="padding: 0 10px; display: flex; align-items: center"
                    v-for="(item, index) in state.formData
                      .gasBaseExFactorySpecificImitateSubIndexList"
                    :key="index"
                  >
                    <el-col :span="3">
                      <el-form-item label="编号"   :prop="`gasBaseExFactorySpecificImitateSubIndexList[${index}].number`"
                        :rules="{
                          required: true,
                          message: '请输入编号',
                          trigger: 'blur',
                        }">
                        <el-input
                          style="width: 160px"
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          clearable
                          v-model="item.number"
                          @change="
                            checkIndex(
                              item.number,
                              index,
                              state.formData.gasBaseExFactorySpecificImitateSubIndexList
                            )
                          "
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <el-form-item label="名称"   :prop="`gasBaseExFactorySpecificImitateSubIndexList[${index}].subIndexName`"
                        :rules="{
                          required: true,
                          message: '请输入名称',
                          trigger: 'blur',
                        }">
                        <el-input
                          clearable
                          style="width: 160px"
                          v-model="item.subIndexName"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <el-form-item label="单位"  :prop="`gasBaseExFactorySpecificImitateSubIndexList[${index}].subIndexUnit`"
                        :rules="{
                          required: true,
                          message: '请输入单位',
                          trigger: 'blur',
                        }"
>
                        <el-input
                          style="width: 160px"
                          clearable
                          v-model="item.subIndexUnit"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item label="低量程">
                        <div class="inputrange fbc">
                          <el-input
                            clearable
                            oninput="value=value.replace(/[^\d.]/g,'')"
                            v-model.number="item.lowRangeUp"
                            placeholder="请输入"
                          >
                          </el-input>
                          <!-- <el-input
                            clearable
                            oninput="value=value.replace(/[^\d.]/g,'')"
                            v-model.number="item.lowRangeUp"
                            placeholder="请输入上限"
                          >
                          </el-input>
                          <span>-</span>
                          <el-input
                            :min="item.lowRangeDown"
                            clearable
                            oninput="value=value.replace(/[^\d.]/g,'')"
                            v-model.number="item.lowRangeDown"
                            placeholder="请输入下限"
                          >
                          </el-input> -->
                        </div>
                      </el-form-item>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item label="高量程">
                        <div class="inputrange fbc">
                          <el-input
                            clearable
                            oninput="value=value.replace(/[^\d.]/g,'')"
                            v-model.number="item.highRangeUp"
                            placeholder="请输入"
                          >
                          </el-input>
                          <!-- <el-input
                            :min="item.lowScaleUp"
                            clearable
                            oninput="value=value.replace(/[^\d.]/g,'')"
                            v-model.number="item.highRangeUp"
                            placeholder="请输入上限"
                          >
                          </el-input>
                          <span>-</span>
                          <el-input
                            :min="item.highRangeDown"
                            clearable
                            oninput="value=value.replace(/[^\d.]/g,'')"
                            v-model.number="item.highRangeDown"
                            placeholder="请输入下限"
                          >
                          </el-input> -->
                        </div>
                      </el-form-item>
                    </el-col>
                    <el-col :span="2" v-if="state.editId">
                        <el-form-item label="引用状态">
                            <el-tag
                        type="success"
                        v-if="item.quoteStatus == 1"
                        @click="
                          yinyong2(
                            state.formData.primaryIndexId,
                            item.childIndexId
                          )
                        "
                        >{{ item.quoteStatus==0?'未引用':'已引用' }}</el-tag
                      >
                      <el-tag v-else>{{ item.quoteStatus==0?'未引用':'已引用' }}</el-tag>
                      </el-form-item>
                    </el-col>
                    <el-col :span="1">
                      <!-- <img
                        v-if="item.quoteStatus == '0'"
                        src="@/assets/icons/svg/删除.svg"
                        alt=""
                      /> -->
                      <svg-icon
                        v-if="
                          item.quoteStatus !== 1 &&
                          state.formData.gasBaseExFactorySpecificImitateSubIndexList.length > 1
                        "
                        class-name="search-icon"
                        icon-class="delkong"
                        @click="delchaildIndexClick(item,index)"
                      />
                    </el-col>
                  </el-row>
                </el-row>
              </div>
              <div v-if="state.tabName == 'switch'">
                <el-row :gutter="20">
                  <el-col :span="6">
                    <el-form-item label="名称" prop="deviceName">
                      <el-input
                        clearable
                        v-model="state.formData.deviceName"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="主索引" prop="primaryIndex">
                      <el-input
                        clearable
                        oninput="value=value.replace(/[^\d]/g,'')"
                        v-model="state.formData.primaryIndex"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="子索引" prop="subIndex">
                      <el-switch
                        v-model="state.formData.subIndex"
                        @click="hasChildChange"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="开关量模式" prop="switchMode">
                      <el-select
                        clearable
                        filterable
                        v-model="state.formData.switchMode"
                        placeholder="请选择"
                      >
                        <el-option
                          v-for="item in state.switchModelList"
                          :key="item.code"
                          :label="item.name"
                          :value="item.code"
                        >
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="常态逻辑" prop="normalLogic">
                      <el-select
                        clearable
                        filterable
                        v-model="state.formData.normalLogic"
                        placeholder="请选择"
                      >
                        <el-option
                          v-for="item in state.normalLogicList"
                          :key="item.code"
                          :label="item.name"
                          :value="item.code"
                        >
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="高电平显示" prop="highLevel">
                      <el-input
                        clearable
                        v-model="state.formData.highLevel"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="低电平显示" prop="lowLevel">
                      <el-input
                        clearable
                        v-model="state.formData.lowLevel"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="24" v-if="state.formData.subIndex">
                    <p class="mask_sub_title fbc">
                      <span>
                        <svg-icon
                          class-name="search-icon"
                          icon-class="dot"
                        />子索引</span
                      >
                      <el-button type="primary" @click="childAddClick" link>
                        <Plus />新增</el-button
                      >
                    </p>
                  </el-col>
                  <el-row
                    v-if="state.formData.subIndex"
                    :gutter="20"
                    style="padding: 0 10px; display: flex; align-items: center"
                    v-for="(item, index) in state.formData
                      .specificSwitchSubIndexList"
                    :key="index"
                  >
                    <el-col :span="3">
                      <el-form-item label="编号" :prop="`specificSwitchSubIndexList[${index}].number`"
                        :rules="{
                          required: true,
                          message: '请输入编号',
                          trigger: 'blur',
                        }">
                        <el-input
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          clearable
                          v-model.number="item.number"
                          @change="
                            checkIndex(
                              item.number,
                              index,
                              state.formData.specificSwitchSubIndexList
                            )
                          "
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <el-form-item label="名称"  :prop="`specificSwitchSubIndexList[${index}].subIndexName`"
                        :rules="{
                          required: true,
                          message: '请输入编号',
                          trigger: 'blur',
                        }">
                        <el-input
                          clearable
                          v-model="item.subIndexName"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <el-form-item label="开关量模式"  :prop="`specificSwitchSubIndexList[${index}].switchMode`"
                        :rules="{
                          required: true,
                          message: '请输入开关量模式',
                          trigger: 'change',
                        }">
                        <el-select
                          clearable
                          filterable
                          v-model="item.switchMode"
                          placeholder="请选择"
                        >
                          <el-option
                            v-for="item in state.switchModelList"
                            :key="item.code"
                            :label="item.name"
                            :value="item.code"
                          >
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <el-form-item label="常态逻辑"  :prop="`specificSwitchSubIndexList[${index}].normalLogic`"
                        :rules="{
                          required: true,
                          message: '请输入常态逻辑',
                          trigger: 'change',
                        }">
                        <el-select
                          clearable
                          filterable
                          v-model="item.normalLogic"
                          placeholder="请选择"
                        >
                          <el-option
                            v-for="item in state.normalLogicList"
                            :key="item.code"
                            :label="item.name"
                            :value="item.code"
                          >
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <el-form-item label="高电平显示"  :prop="`specificSwitchSubIndexList[${index}].highLevel`"
                        :rules="{
                          required: true,
                          message: '请输入高电平显示',
                          trigger: 'blur',
                        }">
                        <el-input
                          clearable
                          v-model="item.highLevel"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <el-form-item label="低电平显示" :prop="`specificSwitchSubIndexList[${index}].lowLevel`"
                        :rules="{
                          required: true,
                          message: '请输入低电平显示',
                          trigger: 'blur',
                        }">
                        <el-input
                          clearable
                          v-model="item.lowLevel"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="2" v-if="state.editId">
                        <el-form-item label="引用状态" prop="">
                      <el-tag
                        type="success"
                        v-if="item.quoteStatus == '0'"
                        @click="
                          yinyong2(
                            state.formData.primaryIndexId,
                            item.childIndexId
                          )
                        "
                        >{{ item.quoteStatus=='0'?'已引用':'未引用' }}</el-tag
                      >
                      <el-tag v-else>{{ item.quoteStatus=='0'?'已引用':'未引用' }}</el-tag>
                    </el-form-item>

                    </el-col>
                    <el-col :span="1">
                      <!-- <img
                        v-if="item.quoteStatus == '0'"
                        src="@/assets/icons/svg/删除.svg"
                        alt=""
                      /> -->
                      <svg-icon
                       v-if="item.quoteStatus !== '0'&&state.formData.specificSwitchSubIndexList.length>1"
                        class-name="search-icon"
                        icon-class="delkong"
                        @click="delchaildIndexClick(item,index)"
                      />
                    </el-col>
                  </el-row>
                </el-row>
              </div>
              <!-- <div v-if="state.tabName =='add'">
                              <el-row :gutter="20">
                                  <el-col :span="5">
                                      <el-form-item label="名称" prop="sensorName">
                                          <el-input clearable  v-model="state.formData.sensorName" placeholder="请输入">
                                          </el-input>
                                      </el-form-item>
                                  </el-col>
                                  <el-col :span="5" v-if="!state.formData.hasChild">
                                      <el-form-item label="单位" prop="sensorUnit">
                                          <el-input clearable v-model="state.formData.sensorUnit" placeholder="请输入">
                                          </el-input>
                                      </el-form-item>
                                  </el-col>
                                  <el-col :span="5">
                                      <el-form-item label="累计周期" prop="resetType">
                                          <el-select clearable v-model="state.formData.resetType" placeholder="请选择">
                                              <el-option v-for="item in state.resetTypeList" :key="item.code"
                                                  :label="item.name" :value="item.code">
                                              </el-option>
                                          </el-select>
                                      </el-form-item>
                                  </el-col>
                                  <el-col :span="5">
                                      <el-form-item label="主索引" prop="primaryIndexId">
                                          <el-input clearable oninput="value=value.replace(/[^\d]/g,'')" v-model="state.formData.primaryIndexId"
                                              placeholder="请输入">
                                          </el-input>
                                      </el-form-item>
                                  </el-col>
                                  <el-col :span="4">
                                      <el-form-item label="子索引" prop="hasChild">
                                          <el-switch v-model="state.formData.hasChild" @change="hasChildChange" />
                                      </el-form-item>
                                  </el-col>
                                  <el-col :span="5" v-if="!state.formData.hasChild">
                                      <el-form-item label="累计模式" prop="orderType">
                                          <el-select clearable v-model="state.formData.orderType" placeholder="请选择">
                                              <el-option v-for="item in state.orderTypeList" :key="item.code"
                                                  :label="item.name" :value="item.code">
                                              </el-option>
                                          </el-select>
                                      </el-form-item>
                                  </el-col>
                                  <el-col :span="5" v-if="!state.formData.hasChild">
                                      <el-form-item label="起始值" prop="startValue">
                                          <el-input oninput="value=value.replace(/[^\d.]/g,'')" clearable v-model="state.formData.startValue" placeholder="请输入">
                                          </el-input>
                                      </el-form-item>
                                  </el-col>
                                  <el-col :span="5" v-if="!state.formData.hasChild">
                                      <el-form-item label="变化值" prop="changeValue">
                                          <el-input oninput="value=value.replace(/[^\d.]/g,'')" clearable v-model="state.formData.changeValue" placeholder="请输入">
                                          </el-input>
                                      </el-form-item>
                                  </el-col>
                                  <el-col :span="5" v-if="!state.formData.hasChild">
                                      <el-form-item label="上限值" prop="upLimitValue">
                                          <el-input oninput="value=value.replace(/[^\d.]/g,'')" clearable v-model="state.formData.upLimitValue" placeholder="请输入">
                                          </el-input>
                                      </el-form-item>
                                  </el-col>
                                  <el-col :span="24" v-if="state.formData.hasChild">
                                      <p class="mask_sub_title fbc">
                                          <span>
                                              <svg-icon class-name="search-icon" icon-class="dot" />子索引</span>
                                          <el-button type="primary" @click="childAddClick" link>
                                              <Plus />新增</el-button>
                                      </p>
                                  </el-col>
                                  <el-row v-if="state.formData.hasChild" :gutter="20"
                                      style="padding:0 10px;display:flex;align-items:center;"
                                      v-for="(item,index) in state.formData.sensorAddChildList" :key="index">
                                      <el-col :span="3">
                                          <el-form-item label="编号">
                                              <el-input oninput="value=value.replace(/[^\d.]/g,'')" clearable
                                                  v-model.number="item.childIndexId" @change="checkIndex(item.childIndexId,index,state.formData.sensorAddChildList)" placeholder="请输入">
                                              </el-input>
                                          </el-form-item>
                                      </el-col>
                                      <el-col :span="3">
                                          <el-form-item label="名称">
                                              <el-input clearable v-model="item.childIndexName" placeholder="请输入">
                                              </el-input>
                                          </el-form-item>
                                      </el-col>
                                      <el-col :span="3">
                                          <el-form-item label="单位" required>
                                              <el-input clearable v-model="item.sensorUnit" placeholder="请输入">
                                              </el-input>
                                          </el-form-item>
                                      </el-col>
                                      <el-col :span="3">
                                          <el-form-item label="累计模式">
                                              <el-select clearable v-model="item.orderType" placeholder="请选择">
                                                  <el-option v-for="item in state.orderTypeList" :key="item.code"
                                                      :label="item.name" :value="item.code">
                                                  </el-option>
                                              </el-select>
                                          </el-form-item>
                                      </el-col>
                                      <el-col :span="3">
                                          <el-form-item label="起始值">
                                              <el-input oninput="value=value.replace(/[^\d.]/g,'')" clearable v-model="item.startValue" placeholder="请输入">
                                              </el-input>
                                          </el-form-item>
                                      </el-col>
                                      <el-col :span="3">
                                          <el-form-item label="变化值">
                                              <el-input oninput="value=value.replace(/[^\d.]/g,'')" clearable v-model="item.changeValue" placeholder="请输入">
                                              </el-input>
                                          </el-form-item>
                                      </el-col>
                                      <el-col :span="3">
                                          <el-form-item label="上限值">
                                              <el-input oninput="value=value.replace(/[^\d.]/g,'')" clearable v-model="item.upLimitValue" placeholder="请输入">
                                              </el-input>
                                          </el-form-item>
                                      </el-col>
                                      <el-col :span="2" v-if="state.editId">
                                          <el-tag type="success" v-if="item.refStatus == '已引用'" @click="yinyong2(state.formData.primaryIndexId,item.childIndexId)">{{item.refStatus}}</el-tag>
                                          <el-tag v-else>{{item.refStatus}}</el-tag>
                                      </el-col>
                                      <el-col :span="1">
                                          <img v-if="item.refStatus == '已引用'" src="@/assets/icons/svg/删除.svg" alt="">
                                          <svg-icon v-else class-name="search-icon" icon-class="delkong"
                                              @click="delchaildIndexClick(index)" />
                                      </el-col>
                                  </el-row>
                              </el-row>
                          </div> -->
            </el-form>
            <div class="form_footer">
              <el-button @click="cancel">取消</el-button>
              <el-button type="primary" @click="submitForm"> 确定 </el-button>
            </div>
          </div>
        </template>
      </vxe-modal>
    </teleport>
  </div>
</template>
<script setup>
import list_controller from "@/components/commonCom/list_controller";
import { useRouter } from "vue-router";
import { computed, onBeforeUpdate, onMounted, reactive } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { table_headers } from "@/components/commonCom/table_headers";
import axios from "@/utils/request";
import {
  getchildIndex,
  getsensorName,
  getunit,
  fileupload,
  getchildIndexadd,
  getsensorNameadd,
} from "@/api/config";
import usePagesStore from "@/store/modules/pages";
const { proxy } = getCurrentInstance();
const store = usePagesStore();
const router = useRouter();
const upload = ref();
const upload1 = ref();
const upload2 = ref();
const validatePass = (rule, value, callback) => {
  let reg = new RegExp(/^\+?[1-9][0-9]*$/);
  if (value == "") {
    return;
  }
  let validParamType = state.options.validParam;
  if (state.tabName == "simulate") {
    validParamType = state.options.validParam;
  } else if (state.tabName == "switch") {
    validParamType = state.options1.validParam;
  } else if (state.tabName == "add") {
    validParamType = state.options2.validParam;
  }
  if (state.editId) {
    axios
      .get(validParamType, {
        params: { type: 1, value: value, id: state.editId },
      })
      .then((res) => {
        if (res.code == 200) {
          state.repeat = false;
          callback();
          if (!reg.test(value)) return callback(new Error("请输入整数"));
        }
      })
      .catch((res) => {
        state.repeat = true;
        return callback(new Error("主索引不能重复"));
      });
  } else {
    axios
      .get(validParamType, { params: { type: 1, value: value } })
      .then((res) => {
        console.log(res);
        if (res.code == 200) {
          state.repeat = false;
          callback();
          if (!reg.test(value)) return callback(new Error("请输入整数"));
        }
      })
      .catch((res) => {
        state.repeat = true;
        return callback(new Error("主索引不能重复"));
      });
  }
  // let reg = new RegExp(/^\+?[1-9][0-9]*$/);
  // if(state.repeat){
  //     return callback(new Error("主索引不能重复"));
  // }else{
  //     callback();
  //     if (!reg.test(value))
  //      return callback(new Error("请输入整数"));
  // }
};
const validatePass2 = (rule, value, callback) => {
  let validParamType = state.options.validParam;
  if (state.tabName == "simulate") {
    validParamType = state.options.validParam;
  } else if (state.tabName == "switch") {
    validParamType = state.options1.validParam;
  } else if (state.tabName == "add") {
    validParamType = state.options2.validParam;
  }
  if (state.editId) {
    axios
      .get(validParamType, {
        params: { type: 0, value: value, id: state.editId },
      })
      .then((res) => {
        if (res.code == 200) {
          state.repeat2 = false;
          callback();
        }
      })
      .catch((res) => {
        state.repeat2 = true;
        return callback(new Error("名称不能重复"));
      });
  } else {
    axios
      .get(validParamType, { params: { type: 0, value: value } })
      .then((res) => {
        if (res.code == 200) {
          state.repeat2 = false;
          callback();
        }
      })
      .catch((res) => {
        state.repeat2 = true;
        return callback(new Error("名称不能重复"));
      });
  }
};
const validatePass3 = (rule, value, callback) => {
  if (value == "") {
    return;
  }
  if (value == state.formData.lowShow) {
    callback(new Error("高低电平显示不能重复"));
  } else {
    callback();
  }
};
const validatePass4 = (rule, value, callback) => {
  if (value == "") {
    return;
  }
  if (value == state.formData.highShow) {
    callback(new Error("高低电平显示不能重复"));
  } else {
    callback();
  }
};
components: {
  list_controller;
}
let state = reactive({
  nowranDis: false,
  noshangwranDis: false,
  tabNameData: "模拟量",
  optionsList: {},
  options: {
    isShowCaozuo: true,
    expandFixed: true,
    tabList: [
      {
        tabIndex: 1,
        name: "模拟量",
      },
      {
        tabIndex: 2,
        name: "开关量",
      },
    ],
    tableheads: computed(() => table_headers.gasBaseExFactorySpecificImitate),
      subtableheads: computed(() => table_headers.gasSpecificImitateSubIndex),
    queryList: {
      dropdownUrl: "",
      querys: [
        {
          field: "deviceName",
          title: "名称",
          type: "input",
          binddata: "",
        },
        {
          field: "primaryIndex",
          title: "主索引",
          type: "select",
          binddata: "",
          options: [],
        },
        {
          field: "subIndex",
          title: "子索引",
          type: "select",
          binddata: "",
          options: [],
        },
      ],
      queryMap: new Map([
        ["sensorTypeId", "safety_pointType"],
        ["deviceTypeId", "safety_deviceType"],
        ["alarmTypeId", "alarmType"],
      ]),
    },
    dataUrl: "/gas/imitate/list", //出厂特性模拟量列表
    delUrl: "/gas/imitate/",
    addUrl: "/gas/imitate/addOutFactoryImitate",
    //   descUrl: '/sensor/simulate/detailSpecial?primaryIndexId=',
    editUrl: "/gas/imitate/updateOutFactoryImitate",
    //   validParam:'/sensor/simulate/validParam',
  },
  options1: {
    isShowCaozuo: true,
    expandFixed: true,
    tabList: [
      {
        tabIndex: 1,
        name: "模拟量",
      },
      {
        tabIndex: 2,
        name: "开关量",
      },
    ],
    tableheads: computed(() => table_headers.gasBaseExFactorySpecificSwitch),
    subtableheads: computed(() => table_headers.gasSpecificSwitchSubIndex),
    queryList: {
      dropdownUrl: "",
      querys: [
        {
          field: "deviceName",
          title: "名称",
          type: "input",
          binddata: "",
        },
        {
          field: "primaryIndex",
          title: "主索引",
          type: "select",
          binddata: "",
          options: [],
        },
        {
          field: "subIndex",
          title: "子索引",
          type: "select",
          binddata: "",
          options: [],
        },
      ],
      queryMap: new Map([
        ["sensorTypeId", "safety_pointType"],
        ["deviceTypeId", "safety_deviceType"],
        ["alarmTypeId", "alarmType"],
      ]),
    },
    dataUrl: "/gas/switch/list", //出厂特性开关量列表
    delUrl: "/gas/switch/",
    addUrl: "/gas/switch/addSwitch",
    //   descUrl: '/sensor/switch/detailSpecial?primaryIndexId=',
    editUrl: "/gas/switch/updateSwitch",
    //   validParam:'/sensor/switch/validParam',
  },
  //   options2: {
  //       expandFixed: true,
  //       tabList: [{
  //           tabIndex: 1,
  //           name: '模拟量'
  //       }, {
  //           tabIndex: 2,
  //           name: '开关量'
  //       }, {
  //           tabIndex: 3,
  //           name: '累计量'
  //       }],
  //       tableheads: computed(() => table_headers.specialAdd),
  //       subtableheads: computed(() => table_headers.specialAddChild),
  //       queryList: {
  //           dropdownUrl: '',
  //           querys: [{
  //               field: 'sensorName',
  //               title: '名称',
  //               type: 'input',
  //               binddata: ''
  //           }],
  //           queryMap: new Map([
  //               ['sensorTypeId', 'safety_pointType'],
  //               ['deviceTypeId', 'safety_deviceType'],
  //               ['alarmTypeId', 'alarmType']
  //           ])
  //       },
  //       dataUrl: '/sensor/add/listSpecial',
  //       delUrl: '/sensor/add/deleteSpecial',
  //       addUrl: '/sensor/add/addSpecial',
  //       descUrl: '/sensor/add/detailSpecial?primaryIndexId=',
  //       editUrl: '/sensor/add/editSpecial',
  //       validParam:'/sensor/add/validParam',
  //   },
  // 表单
  tabName: "simulate",//simulate,switch
  addModal: false,
  modalTitle: "新增模拟量",
  formRef: null,
  formData: {},
  locations: [{}],
  rules: {
    deviceName: [
      {
        required: true,
        message: "请输入名称",
        trigger: "blur",
      },
    //   {
    //     validator: validatePass2,
    //     trigger: "blur",
    //   },
    ],
    primaryIndex: [
      {
        required: true,
        message: "请输入主索引",
        trigger: "blur",
      },
    ],
    subIndex: [
      {
        required: true,
        message: "请选择子索引",
        trigger: "change",
      },
    ],
    unit: [
      {
        required: true,
        message: "请输入单位",
        trigger: "blur",
      },
    ],
    number: [
      {
        required: true,
        message: "请输入编号",
        trigger: "blur",
      },
    ],
    subIndexName: [
      {
        required: true,
        message: "请输入名称",
        trigger: "blur",
      },
    ],
    subIndexUnit: [
              {
        required: true,
        message: "请输入单位",
      },
    ],
//开关量
    switchMode: [
      {
        required: true,
        message: "请选择开关量模式",
        trigger: "change",
      },
    ],
    normalLogic: [
      {
        required: true,
        message: "请选择常态逻辑",
        trigger: "change",
      },
    ],
    highLevel: [
      {
        required: true,
        message: "请输入高电平显示",
        trigger: "blur",
      },
    ],
    lowLevel: [
      {
        required: true,
        message: "请输入低电平显示",
        trigger: "blur",
      },
    ],
    // primaryIndexId: [
    //   {
    //     required: true,
    //     message: "请输入主索引",
    //     trigger: "blur",
    //   },
    //   {
    //     validator: validatePass,
    //     trigger: "blur",
    //   },
    // ],
  },
  editId: undefined,
  resetTypeList: [
    {
      code: 0,
      name: "个数",
    },
    {
      code: 1,
      name: "小时",
    },
    {
      code: 2,
      name: "班",
    },
    {
      code: 3,
      name: "天",
    },
    {
      code: 4,
      name: "月",
    },
    {
      code: 5,
      name: "年",
    },
  ],
  // 下拉数据
  normalLogicList: [
    {
      code: '0',
      name: "低电平",
    },
    {
      code: '1',
      name: "高电平",
    },
  ],
  switchModelList: [
    {
      code: '0',
      name: "二态",
    },
    {
      code: '1',
      name: "三态",
    },
  ],
  orderTypeList: [
    {
      code: '0',
      name: "递增",
    },
    {
      code: '1',
      name: "递减",
    },
  ],
  addeditShow: false,
  repeat: false,
  repeat2: false,
});
// 主索引跳转
const yinyong1 = (row) => {
  console.log(row);
//   router.push({
//     path: "/cspz/basicConfig/deviceChara_analog",
//     query: { primaryIndexId: row.primaryIndexId, tabName: state.tabName },
//   });
};
// 子索引跳转
const yinyong2 = (pId, id) => {
//   router.push({
//     path: "/cspz/basicConfig/deviceChara_analog",
//     query: { primaryIndexId: pId, childIndexId: id, tabName: state.tabName },
//   });
};

// 新增按钮
function addBtn(row) {
  if (state.tabName == "simulate") {
    state.modalTitle = "新增模拟量索引";
  } else if (state.tabName == "switch") {
    state.modalTitle = "新增开关量索引";
  }
  state.addModal = true;
  state.formData = {};
  state.editId = undefined;
  state.addeditShow = true;
}
// 编辑按钮
function editBtn(row) {
  console.log(row, "row");
        state.formData = row;
      state.editId = row.id;
  if (state.tabName == "simulate") {
  row.subIndex=row.gasBaseExFactorySpecificImitateSubIndexList?.length>0?true:false;
    state.modalTitle = "编辑模拟量索引";
  } else if (state.tabName == "switch") {
  row.subIndex=row.specificSwitchSubIndexList?.length>0?true:false;
    state.modalTitle = "编辑开关量索引";
  } 
//   else if (state.tabName == "add") {
//     state.modalTitle = "编辑累计量索引";
//   }
  state.addModal = true;
//   let descUrltype = state.options.descUrl;
//   if (state.tabName == "simulate") {
//     descUrltype = state.options.descUrl;
//   } else if (state.tabName == "switch") {
//     descUrltype = state.options1.descUrl;
//   } else if (state.tabName == "add") {
//     descUrltype = state.options2.descUrl;
//   }
//   axios.get(descUrltype + row.primaryIndexId).then((res) => {
//     if (res.code == 200) {
//       if (res.data.specificSwitchSubIndexList == null) {
//         res.data.specificSwitchSubIndexList = [];
//       }
//       if (res.data.gasBaseExFactorySpecificImitateSubIndexList == null) {
//         res.data.gasBaseExFactorySpecificImitateSubIndexList = [];
//       }
//       if (res.data.sensorAddChildList == null) {
//         res.data.sensorAddChildList = [];
//       }
//       state.formData = res.data;
//       state.editId = res.data.id;
//     }
//   });
  state.addeditShow = false;
}

function deleteBtn(row) {
  let delUrltype = state.options.delUrl;
  if (state.tabName == "simulate") {
    delUrltype = state.options.delUrl;
  } else if (state.tabName == "switch") {
    delUrltype = state.options1.delUrl;
  } 
//   else if (state.tabName == "add") {
//     delUrltype = state.options2.delUrl;
//   }
  let ids = [];
  if (row != "mul") {
    ids = [row.id];
  } else {
    if (store.records.length > 0) {
      ids = store.records.map((item) => {
        return item.id;
      });
    } else {
      proxy.$modal.msgSuccess("请先勾选所要删除数据!");
    }
  }
  if (ids.length > 0) {
    ElMessageBox.confirm("确定要删除吗?", "温馨提示", {
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      type: "warning",
    })
      .then(() => {
        axios.delete(delUrltype+ids).then((res) => {
          if (res.code == 200) {
            proxy.$refs["zujianname"].getData();
            state.addModal = false;
            proxy.$modal.msgSuccess(res.msg);
            store.records = [];
          }
        });
      })
      .catch(() => {
        proxy.$modal.msgWarning("删除取消");
      });
  }
}
// 动态删除行
function delchaildIndexClick(item,index) {
  if (state.tabName == "simulate") {
    console.log(item, "item");
    if(item.id){
        axios.delete("/gas/imitate/index/" + item.id).then((res) => {
      if (res.code == 200) {
        // proxy.$refs["zujianname"].getData();
    state.formData.gasBaseExFactorySpecificImitateSubIndexList.splice(index, 1);
        proxy.$modal.msgSuccess(res.msg);
      }
    });
    }else{
        state.formData.gasBaseExFactorySpecificImitateSubIndexList.splice(index, 1);
    }
   
  } else if (state.tabName == "switch") {
    // state.formData.specificSwitchSubIndexList.splice(index, 1);
    if(item.id){
        axios.delete("/gas/switch/index/" + item.id).then((res) => {
      if (res.code == 200) {
        // proxy.$refs["zujianname"].getData();
        state.formData.specificSwitchSubIndexList.splice(index, 1);
        proxy.$modal.msgSuccess(res.msg);
      }
    });
    }else{
        state.formData.specificSwitchSubIndexList.splice(index, 1);
    }
  } 
}
// /** 提交按钮 */  /sensor/simulate/validParam
function submitForm() {
  let addUrltype = state.options.addUrl;
  let editUrltype = state.options.editUrl;
//   let validParamType = state.options.validParam;
  if (state.tabName == "simulate") {
    addUrltype = state.options.addUrl;
    editUrltype = state.options.editUrl;
  } else if (state.tabName == "switch") {
    addUrltype = state.options1.addUrl;
    editUrltype = state.options1.editUrl;
  } 
//   else if (state.tabName == "add") {
//     addUrltype = state.options2.addUrl;
//     editUrltype = state.options2.editUrl;
//   }
  proxy.$refs["formRef"].validate((valid) => {
    if (valid) {
        // state.formData.primaryIndex=state.formData.primaryIndexId?Number(state.formData.primaryIndexId):null;//主索引
        state.formData.subIndex=state.formData.subIndex==true?1:0;
        state.formData.highRangeDown=0;//高量程下限
        state.formData.lowRangeDown=0;//低量程下限
        if(state.formData
        .gasBaseExFactorySpecificImitateSubIndexList){
          state.formData
          .gasBaseExFactorySpecificImitateSubIndexList.forEach((item) => {
            item.lowRangeDown=0;//低量程下限
            item.highRangeDown=0;//高量程下限
          })
        }
        if(state.formData.subIndex==0){
 state.formData.gasBaseExFactorySpecificImitateSubIndexList=[];  
        }
      if (state.editId) {
        if (true) {
          state.formData.id = state.editId;
          axios.post(editUrltype, state.formData).then((res) => {
            if (res.code == 200) {
              proxy.$refs["zujianname"].getData();
              state.addModal = false;
              proxy.$modal.msgSuccess(res.msg);
            }
          });
        }
      } else {
        console.log(state.formData, "state.formData");
        axios.post(addUrltype, state.formData).then((res) => {
          if (res.code == 200) {
            proxy.$refs["zujianname"].getData();
            state.addModal = false;
            proxy.$modal.msgSuccess(res.msg);
          }
        });
      }
    }
  });
}

function cancel() {
  state.addModal = false;
}

function hasChildChange(val) {
  console.log(val, "val");
  if(val==false){
    state.formData.subIndex=null
  }
    if (state.tabName == "simulate") {
      if (val) {
        state.formData.gasBaseExFactorySpecificImitateSubIndexList = [
          {
            number:'',//编号
        subIndexName:'',//子索引名称
        subIndexUnit:'',//子索引单位
        lowRangeUp:'',//低量程上限
        lowRangeDown:'',//低量程下限
        highRangeUp:'',//高量程上限
        highRangeDown:'',//高量程下限
          },
        ];
      }
    } else if (state.tabName == "switch") {
      if (val) {
        state.formData.specificSwitchSubIndexList = [
          {
            number: "",//子索引编号
            subIndexName: "",//子索引名称
            switchMode: "",//开关量模式
            normalLogic: "",//常态逻辑
            highLevel:"",//高电平显示
            lowLevel:"",//低电平显示
          },
        ];
      }
    } 
//   if (state.addeditShow) {
//     if (state.tabName == "simulate") {
//       if (val) {
//         state.formData.gasBaseExFactorySpecificImitateSubIndexList = [
//           {
//             number:'',//编号
//         subIndexName:'',//子索引名称
//         subIndexUnit:'',//子索引单位
//         lowRangeUp:'',//低量程上限
//         lowRangeDown:'',//低量程下限
//         highRangeUp:'',//高量程上限
//         highRangeDown:'',//高量程下限
//           },
//         ];
//       }
//     } else if (state.tabName == "switch") {
//       if (val) {
//         state.formData.specificSwitchSubIndexList = [
//           {
//             childIndexId: "",
//             childIndexName: "",
//             switchModel: "",
//             normalLogic: "",
//           },
//         ];
//       }
//     } 
//   } else {
//     if (state.tabName == "simulate") {
//       if (val) {
//         state.formData.gasBaseExFactorySpecificImitateSubIndexList = [
//           {
//             childIndexId: "",
//             childIndexName: "",
//             highScaleDown: "",
//             highScaleUp: "",
//             lowScaleDown: "",
//             lowScaleUp: "",
//           },
//         ];
//       }
//     } else if (state.tabName == "switch") {
//       if (val) {
//         state.formData.specificSwitchSubIndexList = [
//           {
//             childIndexId: "",
//             childIndexName: "",
//             switchModel: "",
//             normalLogic: "",
//           },
//         ];
//       }
//     } 
//   }
}

function childAddClick() {
  if (state.tabName == "simulate") {
    state.formData.gasBaseExFactorySpecificImitateSubIndexList.push({
        number:'',//编号
        subIndexName:'',//子索引名称
        subIndexUnit:'',//子索引单位
        lowRangeUp:'',//低量程上限
        lowRangeDown:'',//低量程下限
        highRangeUp:'',//高量程上限
        highRangeDown:'',//高量程下限
    });
  } else if (state.tabName == "switch") {
    state.formData.specificSwitchSubIndexList.push({
            number: "",//子索引编号
            subIndexName: "",//子索引名称
            switchMode: "",//开关量模式
            normalLogic: "",//常态逻辑
            highLevel:"",//高电平显示
            lowLevel:"",//低电平显示
          },);
  } 
}
tabChange('模拟量')

function tabChange(val) {
  state.formData = {};
  state.tabNameData = val;
  if (val == "模拟量") {
    state.optionsList = state.options;
    // setTimeout(() => {
    //   proxy.$refs["zujianname"].getData();
    // }, 200);
    state.tabName = "simulate";
    // state.modalTitle = "新增模拟";
  } 
   if (val == "开关量") {
    state.optionsList = state.options1;
    // setTimeout(() => {
    //   proxy.$refs["zujianname"].getData();
    // }, 200);
    state.tabName = "switch";
    // state.modalTitle = "新增开关";
  }
  setTimeout(() => {
    getSelectList();
      proxy.$refs["zujianname"].getData();
    }, 200);
}
// state.optionsList = state.options;
function getSelectList(val) {
  let moniArr = [];
  let moniArr2 = [];
  let kaiguanArr = [];
  let kaiguanArr2 = [];
  axios
    .post(state.optionsList.dataUrl, {
      pageNum: 1,
      pageSize: 999,
    })
    .then((res) => {
      if (res.rows) {
        if (state.tabNameData == "模拟量") {
          moniArr = res.rows.map((item) => {
            return { label: item.primaryIndex, value: item.primaryIndex };
          });
          moniArr = [...new Set(moniArr.map((t) => JSON.stringify(t)))].map(
            (s) => JSON.parse(s)
          );
          state.options.queryList.querys[1].options = moniArr;
          moniArr2 = res.rows.map((item) => {
            return { label: item.subIndex, value: item.subIndex };
          });
          moniArr2 = [...new Set(moniArr2.map((t) => JSON.stringify(t)))].map(
            (s) => JSON.parse(s)
          );
          state.options.queryList.querys[2].options = moniArr2;
        } else if (state.tabNameData == "开关量") {
          kaiguanArr = res.rows.map((item) => {
            return { label: item.primaryIndex, value: item.primaryIndex };
          });
          kaiguanArr = [
            ...new Set(kaiguanArr.map((t) => JSON.stringify(t))),
          ].map((s) => JSON.parse(s));
          state.options1.queryList.querys[1].options = kaiguanArr;
          kaiguanArr2 = res.rows.map((item) => {
            return { label: item.subIndex, value: item.subIndex };
          });
          kaiguanArr2 = [
            ...new Set(kaiguanArr2.map((t) => JSON.stringify(t))),
          ].map((s) => JSON.parse(s));
          state.options1.queryList.querys[2].options = kaiguanArr2;
        }
      }
    });
}
// 校验编号是否重复
const checkIndex = (val, index, arr2) => {
  let bl = true;
  let arr = JSON.parse(JSON.stringify(arr2));
  arr.splice(index, 1);
  arr.forEach((item) => {
    if (item.childIndexId == val) {
      bl = false;
    }
  });
  if (!bl) {
    ElMessage.error("编号不能重复");
    arr2[index].childIndexId = null;
  }
};
// 检验名称是否重复
const checkName = (val) => {
  let validParamType = state.options.validParam;
  if (state.tabName == "simulate") {
    validParamType = state.options.validParam;
  } else if (state.tabName == "switch") {
    validParamType = state.options1.validParam;
  } else if (state.tabName == "add") {
    validParamType = state.options2.validParam;
  }
  if (state.editId) {
    axios
      .get(validParamType, {
        params: { type: 0, value: val, id: state.editId },
      })
      .then((res) => {
        if (res.code == 200) {
          state.repeat2 = false;
        }
      })
      .catch((res) => {
        state.repeat2 = true;
      });
  } else {
    axios
      .get(validParamType, { params: { type: 0, value: val } })
      .then((res) => {
        if (res.code == 200) {
          state.repeat2 = false;
        }
      })
      .catch((res) => {
        state.repeat2 = true;
      });
  }
};
// 检验主索引是否重复
const checkIndexId = (val) => {
  if (val == "") {
    return;
  }
  let validParamType = state.options.validParam;
  if (state.tabName == "simulate") {
    validParamType = state.options.validParam;
  } else if (state.tabName == "switch") {
    validParamType = state.options1.validParam;
  } else if (state.tabName == "add") {
    validParamType = state.options2.validParam;
  }
  if (state.editId) {
    axios
      .get(validParamType, {
        params: { type: 1, value: val, id: state.editId },
      })
      .then((res) => {
        if (res.code == 200) {
          state.repeat = false;
        }
      })
      .catch((res) => {
        state.repeat = true;
      });
  } else {
    axios
      .get(validParamType, { params: { type: 1, value: val } })
      .then((res) => {
        console.log(res);
        if (res.code == 200) {
          state.repeat = false;
        }
      })
      .catch((res) => {
        state.repeat = true;
      });
  }
};
</script>
<style scoped lang="scss">
.inputrange {
  background: rgba(91, 109, 128, 0.08);

  ::v-deep .el-input__wrapper {
    box-shadow: none;
    background: rgba(91, 109, 128, 0);
  }
}
.form_box {
  max-height: 580px;
  overflow: auto;
}
</style>